@extends('layouts.back_stage')
@section('content')
    <style>
        .addCode{float:right;margin-right:30px;}
        .shopBg{background:#fff;overflow: hidden;margin:20px 0 10px 0;}
        .tableBg{padding:30px;background:#fff;}
        ::-webkit-scrollbar {height: 8px;}
        .el-select .el-input .el-select__caret.el-input__icon{line-height:22px;}
        .input-item{width:200px;padding-right: 0;margin:20px 10px 20px 0;}
        .el-table__footer-wrapper tbody td, .el-table__header-wrapper tbody td{color:red;}
        .timeDuan{margin:20px 0;}
        .input-time{width:220px;margin-right:10px;}
        .pagination-box{text-align: center;box-sizing:border-box;margin-top:20px;}
        .el-range-editor--small.el-input__inner{width:300px;}
        .el-date-editor .el-range-separator{padding:0 15px}
        .el-textarea{width:400px;}
        .touching{float:right;margin-right:30px;}
        .el-button+.el-button.picking{float:right;margin-right:15px;margin-left:0;}
        [v-cloak] {display: none;}
    </style>

    <div class="container">
        <div style="padding:20px 20px 20px 0;overflow:hidden;"><h3 style="float:left;">订单调整管理</h3></div>
        <!-- 主体-->
        <div class="page-body">
            <div class="row app" id="shopInfos" v-cloak>
                <el-button type="primary" class="touching" size="small" @click="cancelPeople">取消客户订单</el-button>
                {{--<el-button type="primary" class="picking" size="small" >取消单码</el-button>--}}
                <el-button type="primary" class="picking" size="small" @click="changeColor">改变颜色</el-button>
                <el-button type="primary" class="picking" size="small" @click="changeGirard">改变款号</el-button>
                <el-button type="primary" class="picking" size="small" @click="cancelColor">取消单色</el-button>
                <el-button type="primary" class="picking" size="small" @click="cancelGirard">取消单款</el-button>
                <div class="col-md-12 row row-table-box">
                    <div class="shopBg">
                        <div class="row" style="margin-top:10px;padding:6px 30px;min-height:90px;background:#fff;">
                            <label>销售季节：</label>
                            <el-select v-model="sale_season_id" filterable placeholder="请选择销售季节" size="small" style="width:200px;">
                                <el-option v-for="item in options1" :key="item.id" :label="item.name" :value="item.id"></el-option>
                            </el-select>
                            <label>品牌：</label>
                            <el-select v-model="brand_id" filterable placeholder="请选择品牌" size="small" style="width:200px;">
                                <el-option v-for="item in options2" :key="item.id" :label="item.brand_name" :value="item.id"></el-option>
                            </el-select>
                            <label>款号：</label>
                            <el-input v-model.trim="girard" class="input-item" placeholder="请输入款号" size="small" prefix-icon="el-icon-search" clearable></el-input>
                            <el-button type="primary" size="small" @click="grabble1('reset')">搜索</el-button>
                            <el-button type="primary" size="small" @click="resetSou('reset')">重置</el-button>
                        </div>
                    </div>
                    <div class="tableBg" style="margin-top:10px;height:1000px;">
                        <div style="width:48%;float:left;">
                            <el-table :data="countInfo" max-height="1000" size="mini" border :summary-method="getSummaries1" show-summary @row-click="rowClick1" @selection-change="handleSelectionChange1">
                                <el-table-column type="selection" width="50"></el-table-column>
                                <el-table-column prop="loop" label="序号" width="50" :resizable='false'></el-table-column>
                                <el-table-column prop="year" label="年份" width="50" :resizable='false'></el-table-column>
                                <el-table-column prop="season" label="季节" width="50" :resizable='false'></el-table-column>
                                <el-table-column prop="cate_3" label="小类" width="100" :resizable='false'></el-table-column>
                                <el-table-column prop="girard" label="款号" width="100" :resizable='false'></el-table-column>
                                <el-table-column prop="price" label="吊牌价/元" align="right" width="130" :resizable='false'></el-table-column>
                                <el-table-column prop="nums" label="数量/件" width="100" :resizable='false'></el-table-column>
                                <el-table-column prop="count" label="吊牌总额/元" align="right" min-width="130" :resizable='false'></el-table-column>
                            </el-table>
                            <div class="pagination-box">
                                <el-pagination @size-change="handleSizeChange1" :page-sizes="[20,50,100,200]" :page-size="20" @current-change="changePageSkip1" :current-page.sync="currentPage1" :total="total1" layout="sizes,prev, pager, next" background></el-pagination>
                            </div>
                        </div>
                        <div style="width:48%;float:right;" v-show="showTwo">
                            <el-table :data="twoInfo" max-height="510" style="width: 100%;" size="mini" border :summary-method="getSummaries2" show-summary @row-click="rowClick2" @selection-change="handleSelectionChange2">
                                <el-table-column type="selection" width="50"></el-table-column>
                                <el-table-column type="index" label="序号" width="50" :resizable='false'></el-table-column>
                                <el-table-column prop="girard" width="100" label="款号" :resizable='false'></el-table-column>
                                <el-table-column prop="color" width="100" label="颜色" :resizable='false'></el-table-column>
                                <el-table-column prop="price" label="吊牌价/元" align="right" width="130" :resizable='false'></el-table-column>

                                <el-table-column v-for="item in sizeGr" :prop="item.lab" :label="item.size" width="50" :resizable='false'></el-table-column>

                                <el-table-column prop="count" label="合计/件" width="100" :resizable='false'></el-table-column>
                                <el-table-column prop="couPrice" label="金额/元" align="right" width="130" :resizable='false'></el-table-column>
                            </el-table>
                        </div>
                        <div style="width:48%;float:right;margin-top: 50px;" v-show="showThree">
                            <el-table :data="threeInfo" max-height="1000" size="mini" border :summary-method="getSummaries2" show-summary @selection-change="handleSelectionChange3">
                                <el-table-column type="selection" width="50"></el-table-column>
                                <el-table-column prop="loop" label="序号" width="50" :resizable='false'></el-table-column>
                                <el-table-column prop="client_name" label="代理商" width="180" :resizable='false'></el-table-column>
                                <el-table-column prop="girard" label="款号" width="100" :resizable='false'></el-table-column>
                                <el-table-column prop="color" width="100" label="颜色" :resizable='false'></el-table-column>
                                <el-table-column prop="price" label="吊牌价/元" align="right" width="130" :resizable='false'></el-table-column>

                                <el-table-column v-for="item in sizeSmall" :prop="item.lab"  :label="item.size" width="50" :resizable='false'></el-table-column>

                                <el-table-column prop="count" label="合计/件" width="100" :resizable='false'></el-table-column>
                                <el-table-column prop="couPrice" label="金额/元" align="right" width="130" :resizable='false'></el-table-column>
                            </el-table>
                            <div class="pagination-box">
                                <el-pagination @current-change="changePageSkip2" :current-page="currentPage2" :total="total2" layout="prev, pager, next" background></el-pagination>
                            </div>
                        </div>
                    </div>
                </div>
                <el-dialog title="改变款号" :visible.sync="showBox1" class="add-box" width="30%">
                    <el-form :model="addAct1">
                        <el-form-item label="款号" label-width="100px">
                            {{--<el-select v-model="addAct.type_id" filterable placeholder="请选择入仓仓库(必)" size="small" class="panType" style="width:95%">--}}
                                {{--<el-option v-for="item in options2" :key="item.value" :label="item.text" :value="item.value"></el-option>--}}
                            {{--</el-select>--}}
                            <el-input v-model="addAct1.girard" class="input-info" size="small" placeholder="请输入款号(必)" ></el-input>
                        </el-form-item>
                    </el-form>
                    <div slot="footer" class="dialog-footer">
                        <el-button @click="showBox1 = false" size="small">取 消</el-button>
                        <el-button type="primary" @click="sureBtn1" size="small">确 定</el-button>
                    </div>
                </el-dialog>
                <el-dialog title="改变颜色" :visible.sync="showBox2" class="add-box" width="30%">
                    <el-form :model="addAct2">
                        <el-form-item label="颜色" label-width="100px">
                            {{--<el-select v-model="addAct.type_id" filterable placeholder="请选择入仓仓库(必)" size="small" class="panType" style="width:95%">--}}
                            {{--<el-option v-for="item in options2" :key="item.value" :label="item.text" :value="item.value"></el-option>--}}
                            {{--</el-select>--}}
                            <el-input v-model="addAct2.color" class="input-info" size="small" placeholder="请输入颜色(必)" ></el-input>
                        </el-form-item>
                    </el-form>
                    <div slot="footer" class="dialog-footer">
                        <el-button @click="showBox2 = false" size="small">取 消</el-button>
                        <el-button type="primary" @click="sureBtn2" size="small">确 定</el-button>
                    </div>
                </el-dialog>
            </div>
        </div>
        <!-- /主体-->
    </div>
    <script>
        new Vue({
            el: '#shopInfos',
            data:{
                /*搜索条件*/
                options1:[],//销售季节存储
                sale_season_id:'',//销售季节
                options2:[],//品牌存储
                brand_id:'',//品牌
                girard:'',//款号

                ids:'',//一级多选框款号拼起来
                ids2:'',//二级多选框颜色拼起来
                ids22:'',//二级多选框款号拼起来
                ids3:'',//三级多选框客户id拼起来
                ids3Color:'',//三级多选框客户颜色拼起来
                ids3Girard:'',//三级多选框客户款号拼起来

                countInfo:[], //表单数据
                total1:1,  //table总条数
                page1:20,//每页多少条
                currentPage1:1, //table当前页数
                girardNum1:'',//款号种类合计
                couNum:'',//数量合计

                twoInfo:[], //表单数据
                showTwo:false,

                threeInfo:[], //表单数据
                showThree:false,
                total2:1,  //table总条数
                page2:10,//每页多少条
                currentPage2:1, //table当前页数
                girardNum2:'',//款号种类合计
                couNum2:'',//数量合计



                sizeGr: [],//二级尺码
                sizeSmall:[],//三级

                remOne:'',//记忆一级款号
                remTwoColor:'',//记忆二级颜色
                remTwoGirard:'',//记忆二级款号

                showBox1:false,//修改款号弹框
                oldGirard:'',//旧款号
                addAct1:{
                    girard:'',//款号
                },

                showBox2:false,//修改款号弹框
                oldGir:'',//旧款号
                oldCol:'',//旧颜色
                addAct2:{
                    color:'',//颜色
                },

                cancelGirardFlag:true,
                cancelColorFlag:true,
                cancelPeopleFlag:true,
            },
            mounted(){
                this.base();
            },
            methods:{
                /*获取销售季节，品牌*/
                base(){
                    var that = this;
                    $.ajax({
                        headers: {
                            'X-CSRF-TOKEN': $('meta[name="csrf_token"]').attr('content')
                        },
                        type: 'post',
                        url: '/allotment-manager/brand-season',
                        data: {},
                        success: function (data) {
                            //console.log(data);
                            if(data.result.success){
                                that.options1 = data.content.season;
                                that.options2 = data.content.brand;
                            }else{
                                that.$notify.error({
                                    title: '提示',
                                    message: data.result.errorMsg,
                                });
                            }
                        }
                    });
                },
                //一级获取数据
                grabble1(type)  {
                    var that = this;
                    let skip;
                    if(type == 'reset'){
                        skip = 0;
                    }else{
                        skip = that.currentPage-1;
                    }
                    $.ajax({
                        headers: {
                            'X-CSRF-TOKEN': $('meta[name="csrf_token"]').attr('content')
                        },
                        type: 'post',
                        url: '/allotment-manager/order-girard-list',
                        data: {
                            skip:skip,
                            page1:that.page1,
                            sale_season_id:this.sale_season_id,
                            brand_id:this.brand_id,
                            girard:this.girard,
                        },
                        success: function (data) {
                            //console.log(data);
                            if(data.result.success){
                                if(data.content.data.length<=0){
                                    that.$notify.error({
                                        title: '提示',
                                        message: "该搜索条件没有数据",
                                    });
                                };
                                var opt=[];
                                let girardArr=[];
                                let i = 0;
                                let shuLiang=0;
                                for(var value of data.content.data){
                                    if(girardArr.indexOf(value.girard)==-1){
                                        girardArr.push(value.girard)
                                    };
                                    if(value.nums.indexOf("/")!=-1){
                                        let nuArr=value.nums.split("/");
                                        shuLiang=Number( shuLiang ) + Number( nuArr[0] ) + Number( nuArr[1] );
                                    }else{
                                        shuLiang=Number( shuLiang ) + Number( value.nums );
                                    }
                                    i++;
                                    opt.push({
                                        'loop':i+(Number(that.page1)*skip),
                                        'year':value.year,
                                        'season':value.season,
                                        'cate_3':value.cate_3,
                                        'girard':value.girard,
                                        'price':value.price,
                                        'nums':value.nums,
                                        'count':that.getDon(value.price,value.nums),
                                    })
                                }
                                that.girardNum1=girardArr.length;
                                that.couNum=shuLiang;
                                that.countInfo = opt;
                                that.total = data.content.total;
                                that.currentPage = data.content.skip;
                            }else{
                                that.$notify.error({
                                    title: '提示',
                                    message: data.result.errorMsg,
                                });
                            }
                        }
                    });
                },
                /*总额*/
                getDon(price,nums){
                    if(price.indexOf("/")!=-1 && nums.indexOf("/")!=-1){
                        let priArr=price.split("/");
                        let numsArr=price.split("/");
                        let disOne=(priArr[0]*numsArr[0]);
                        let disTwo=(priArr[1]*numsArr[1]);
                        return (Number(disOne) + Number(disTwo)).toFixed(2);
                    }else{
                        return (price*nums).toFixed(2);
                    }
                },
                /*重置*/
                resetSou(){
                    this.sale_season_id='';
                    this.brand_id='';
                    this.girard='';
                    this.countInfo=[];
                    this.showTwo=false;
                    this.showThree=false;
                },
                /*一级每页条数*/
                handleSizeChange1(val) {
                    this.page1=val;
                    this.grabble1('reset');
                    //console.log(`每页 ${val} 条`);
                },
                /*一级分页*/
                changePageSkip1(val){
                    //console.log(val);
                    this.currentPage1 = val;
                    this.grabble1();
                },
                /*一级多选*/
                handleSelectionChange1(val){
                    if(val.length>0){
                        var st='';
                        for(var value of val){
                            st=st+value.girard+',';
                        }
                        this.ids=st.substr(0, st.length - 1);
                    }else{
                        this.ids='';
                    }
                    console.log(this.ids);
                },
                /*合计*/
                getSummaries1(param) {
                    var that=this;
                    const { columns, data } = param;
                    const sums = [];
                    columns.forEach((column, index) => {
                        if (index === 0) {
                            sums[index] = '合计';
                            return;
                        }
                        const values = data.map(item => Number(item[column.property]));
                        switch (column.property) {
                            case 'girard':
                                sums[index] = that.girardNum1;
                                break;
                            case 'nums':
                                sums[index] = that.couNum;
                                break;
                            case 'count':
                                sums[index] = values.reduce((prev, curr) => {
                                    const value = Number(curr);
                                    if (!isNaN(value)) {
                                        return ( parseFloat(prev) + parseFloat(curr) ).toFixed(2);
                                    } else {
                                        return parseFloat(prev).toFixed(2);
                                    }
                                }, 0);
                                break;
                            default:
                                break;
                        }
                    });
                    return sums
                },
                /*一级点击出二级数据*/
                rowClick1(row, event, column) {
                    //console.log(row)
                    var that=this;
                    /*当事件源是a的时候，我们不展开*/
                    let nodeName = event.target.nodeName;
                    //console.log(nodeName)
                    if(nodeName==='BUTTON'){
                        return;
                    }
                    if(nodeName==='SPAN'){
                        return;
                    }
                    that.remOne=row.girard;//记忆款号，单色取消用得到
                    that.grabble2(row.girard);
                },
                /*总吊牌额*/
                getPr(price,nums){
                    if(price.indexOf("/")!=-1){
                        let priArr=price.split("/");
                        let disOne=(priArr[0]*nums);
                        let disTwo=(priArr[1]*nums);
                        return (Number(disOne) + Number(disTwo)).toFixed(2);
                    }else{
                        return (price*nums).toFixed(2);
                    }
                },
// --------------------------
                //二级数据数据
                grabble2(girard) {
                    var that = this;
                    $.ajax({
                        headers: {
                            'X-CSRF-TOKEN': $('meta[name="csrf_token"]').attr('content')
                        },
                        type: 'post',
                        url: '/allotment-manager/girard-order-info',
                        data: {
                            girard:girard
                        },
                        success: function (data) {
                            //console.log(data);
                            if(data.result.success){
                                that.sizeGr=data.content.size_group;
                                var opt1 = [];
                                let i = 0;
                                for (var value of data.content.data) {
                                    var cvs=0;
                                    for(var cv=0;cv<value.nums.length;cv++){
                                        if(value.nums[cv]==''){
                                            value.nums[cv]=0;
                                        }
                                        cvs+=Number(value.nums[cv]);
                                    }
                                    i++;
                                    opt1.push({
                                        'girard': value.girard,
                                        'color': value.color,
                                        'price': value.price,
                                        'num': value.nums,
                                        'count':cvs,
                                        'couPrice': that.getPr(value.price,cvs),
                                    })
                                }
                                that.twoInfo = opt1;
                                that.showTwo=true;
                            }else{
                                that.$notify.error({
                                    title: '提示',
                                    message: data.result.errorMsg,
                                });
                            }
                        }
                    });
                },
                /*二级多选*/
                handleSelectionChange2(val){
                    if(val.length>0){
                        var st='';
                        var st2='';
                        for(var value of val){
                            st=st+value.color+',';
                            st2=st2+value.girard+',';
                        }
                        this.ids2=st.substr(0, st.length - 1);
                        this.ids22=st2.substr(0, st2.length - 1);
                    }else{
                        this.ids2='';
                        this.ids22='';
                    }
                    //console.log(this.ids2);
                },
                /*二级合计*/
                getSummaries2(param) {
                    var that=this;
                    const { columns, data } = param;
                    const sums = [];
                    columns.forEach((column, index) => {
                        if (index === 0) {
                            sums[index] = '合计';
                            return;
                        }
                        const values = data.map(item => Number(item[column.property]));
                        switch (column.property) {
                            case 'count':
                                sums[index] = values.reduce((prev, curr) => {
                                    const value = Number(curr);
                                    if (!isNaN(value)) {
                                        return prev + curr;
                                    } else {
                                        return prev;
                                    }
                                }, 0);
                                break;
                            case 'couPrice':
                                sums[index] = values.reduce((prev, curr) => {
                                    const value = Number(curr);
                                    if (!isNaN(value)) {
                                        return ( parseFloat(prev) + parseFloat(curr) ).toFixed(2);
                                    } else {
                                        return parseFloat(prev).toFixed(2);
                                    }
                                }, 0);
                                break;
                            default:
                                break;
                        }
                    });
                    return sums
                },
                /*二级点击出三级数据*/
                rowClick2(row, event, column) {
                    //console.log(row)
                    var that=this;
                    /*当事件源是a的时候，我们不展开*/
                    let nodeName = event.target.nodeName;
                    //console.log(nodeName)
                    if(nodeName==='BUTTON'){
                        return;
                    }
                    if(nodeName==='SPAN'){
                        return;
                    }
                    that.remTwoColor=row.color;//记忆颜色，客户取消用得到
                    that.remTwoGirard=row.girard;//记忆款号，客户取消用得到
                    that.grabble3(row.girard,row.color);
                },
                //三级数据数据
                grabble3(girard,color) {
                    var that = this;
                    var skip=that.currentPage2-1;
                    $.ajax({
                        headers: {
                            'X-CSRF-TOKEN': $('meta[name="csrf_token"]').attr('content')
                        },
                        type: 'post',
                        url: '/allotment-manager/girard-client-order-info',
                        data: {
                            skip:skip,
                            page2:that.page2,
                            girard:girard,
                            color:color,
                        },
                        success: function (data) {
                            //console.log(data);
                            if(data.result.success){
                                that.sizeSmall=data.content.size_group;
                                var opt1 = [];
                                let i = 0;
                                for (var value of data.content.data) {
                                    var cvs=0;
                                    for(var cv=0;cv<value.nums.length;cv++){
                                        if(value.nums[cv]==''){
                                            value.nums[cv]=0;
                                        }
                                        cvs+=Number(value.nums[cv]);
                                    }
                                    i++;
                                    opt1.push({
                                        'loop':i+(10*skip),
                                        'client_id':value.client_id,
                                        'client_name':value.client_name,
                                        'girard': value.girard,
                                        'color': value.color,
                                        'price': value.price,
                                        'num': value.nums,
                                        'count':cvs,
                                        'couPrice': that.getPr(value.price,cvs),
                                    })
                                }
                                that.threeInfo = opt1;
                                that.total2 = data.content.total;
                                that.currentPage2 = data.content.skip;
                                that.showThree=true;
                            }else{
                                that.$notify.error({
                                    title: '提示',
                                    message: data.result.errorMsg,
                                });
                            }
                        }
                    });
                },
                /*三级分页*/
                changePageSkip2(val){
                    //console.log(val);
                    this.currentPage2 = val;
                    this.grabble3();
                },
                /*三级多选*/
                handleSelectionChange3(val){
                    console.log(val)
                    if(val.length>0){
                        var st='';
                        var sColor='';
                        var sGirard='';
                        for(var value of val){
                            st=st+value.client_id+',';
                            sColor=sColor+value.color+',';
                            sGirard=sGirard+value.girard+',';
                        }
                        this.ids3=st.substr(0, st.length - 1);
                        this.ids3Color=sColor.substr(0, sColor.length - 1);
                        this.ids3Girard=sGirard.substr(0, sGirard.length - 1);

                    }else{
                        this.ids3='';
                        this.ids3Color='';
                        this.ids3Girard='';
                    }
                    console.log(this.ids3);
                },
                /*合计*/
                getSummaries2(param) {
                    var that=this;
                    const { columns, data } = param;
                    const sums = [];
                    columns.forEach((column, index) => {
                        if (index === 0) {
                            sums[index] = '合计';
                            return;
                        }
                        const values = data.map(item => Number(item[column.property]));
                        switch (column.property) {
                            case 'nums':
                                sums[index] = that.couNum;
                                break;
                            case 'count':
                                sums[index] = values.reduce((prev, curr) => {
                                    const value = Number(curr);
                                    if (!isNaN(value)) {
                                        return prev + curr;
                                    } else {
                                        return prev;
                                    }
                                }, 0);
                                break;
                            case 'couPrice':
                                sums[index] = values.reduce((prev, curr) => {
                                    const value = Number(curr);
                                    if (!isNaN(value)) {
                                        return ( parseFloat(prev) + parseFloat(curr) ).toFixed(2);
                                    } else {
                                        return parseFloat(prev).toFixed(2);
                                    }
                                }, 0);
                                break;
                            default:
                                break;
                        }
                    });
                    return sums
                },
//--------------------------
                /*取消单款*/
                cancelGirard(){
                    var that=this;
                    if(this.ids==''){
                        this.$notify.error({
                            title: '提示',
                            message: "请选择一项款号取消",
                        });
                        return false;
                    }
                    if(this.ids.split(",").length>=2){
                        this.$notify.error({
                            title: '提示',
                            message: "请选择一项款号取消",
                        });
                        return false;
                    }
                    const h = this.$createElement;
                    this.$msgbox({
                        title: '提示',
                        message: h('p', null, [
                            h('span', null, '是否确认取消该款号?'),
                        ]),
                        showCancelButton: true,
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        type: 'warning',
                        beforeClose: (action, instance, done) => {
                            if (action === 'confirm') {
                                if(that.cancelGirardFlag==true){
                                    that.cancelGirardFlag=false;
                                    $.ajax({
                                        headers: {
                                            'X-CSRF-TOKEN': $('meta[name="csrf_token"]').attr('content')
                                        },
                                        type: 'post',
                                        url: '/allotment-manager/cancel-single-girard',
                                        data: {
                                            girard:that.ids,
                                        },
                                        success: function (data) {
                                            //console.log(data);
                                            if(data.result.success){
                                                that.$notify.success({
                                                    title: '提示',
                                                    message: "取消单款成功",
                                                });
                                                that.grabble1('reset');
                                                that.showTwo=false;
                                                that.showThree=false;
                                                done();
                                                that.cancelGirardFlag=true;
                                            }else{
                                                that.$notify.error({
                                                    title: '提示',
                                                    message: data.result.errorMsg,
                                                });
                                                that.cancelGirardFlag=true;
                                            }
                                        }
                                    });
                                }
                            } else {
                                done();
                            }
                        }
                    }).then(action => {

                    });
                },
                /*取消单色*/
                cancelColor(){
                    var that=this;
                    if(this.ids2==''){
                        this.$notify.error({
                            title: '提示',
                            message: "请选择一项颜色取消",
                        });
                        return false;
                    }
                    if(this.ids2.split(",").length>=2){
                        this.$notify.error({
                            title: '提示',
                            message: "请选择一项颜色取消",
                        });
                        return false;
                    }
                    const h = this.$createElement;
                    this.$msgbox({
                        title: '提示',
                        message: h('p', null, [
                            h('span', null, '是否确认取消该颜色?'),
                        ]),
                        showCancelButton: true,
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        type: 'warning',
                        beforeClose: (action, instance, done) => {
                            if (action === 'confirm') {
                                if(that.cancelColorFlag==true){
                                    that.cancelColorFlag=false;
                                    $.ajax({
                                        headers: {
                                            'X-CSRF-TOKEN': $('meta[name="csrf_token"]').attr('content')
                                        },
                                        type: 'post',
                                        url: '/allotment-manager/cancel-single-color',
                                        data: {
                                            color:that.ids2,
                                            girard:that.ids22,
                                        },
                                        success: function (data) {
                                            //console.log(data);
                                            if(data.result.success){
                                                that.$notify.success({
                                                    title: '提示',
                                                    message: "取消单色成功",
                                                });
                                                that.grabble2(that.remOne);
                                                that.showThree=false;
                                                done();
                                                that.cancelColorFlag=true;
                                            }else{
                                                that.$notify.error({
                                                    title: '提示',
                                                    message: data.result.errorMsg,
                                                });
                                                that.cancelColorFlag=true;
                                            }
                                        }
                                    });
                                }
                            } else {
                                done();
                            }
                        }
                    }).then(action => {

                    });
                },
                /*改变款号*/
                changeGirard(){
                    var that=this;
                    if(this.ids==''){
                        this.$notify.error({
                            title: '提示',
                            message: "请选择一项款号修改",
                        });
                        return false;
                    }
                    if(this.ids.split(",").length>=2){
                        this.$notify.error({
                            title: '提示',
                            message: "请选择一项款号修改",
                        });
                        return false;
                    }
                    const h = this.$createElement;
                    this.$msgbox({
                        title: '提示',
                        message: h('p', null, [
                            h('span', null, '是否确认修改该款号?'),
                        ]),
                        showCancelButton: true,
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        type: 'warning',
                        beforeClose: (action, instance, done) => {
                            if (action === 'confirm') {
                                that.showBox1=true;
                                that.oldGirard=that.ids;
                                that.addAct1.girard=that.ids;
                                done();
                            } else {
                                done();
                            }
                        }
                    }).then(action => {

                    });
                },
                /*改变款号确定*/
                sureBtn1(){
                    var that=this;
                    if(this.addAct1.girard==''){
                        this.$notify.error({
                            title: '提示',
                            message: "请填写款号",
                        });
                        return false;
                    }
                    $.ajax({
                        headers: {
                            'X-CSRF-TOKEN': $('meta[name="csrf_token"]').attr('content')
                        },
                        type: 'post',
                        url: '/allotment-manager/change-girard',
                        data: {
                            new_girard:that.addAct1.girard,
                            girard:that.oldGirard,
                        },
                        success: function (data) {
                            //console.log(data);
                            if(data.result.success){
                                that.$notify.success({
                                    title: '提示',
                                    message: "修改款号成功",
                                });
                                that.grabble1('reset');
                                that.showTwo=false;
                                that.showThree=false;
                                that.showBox1=false;
                            }else{
                                that.$notify.error({
                                    title: '提示',
                                    message: data.result.errorMsg,
                                });
                            }
                        }
                    });
                },
                /*改变颜色*/
                changeColor(){
                    var that=this;
                    if(this.ids2==''){
                        this.$notify.error({
                            title: '提示',
                            message: "请选择一个颜色修改",
                        });
                        return false;
                    }
                    if(this.ids2.split(",").length>=2){
                        this.$notify.error({
                            title: '提示',
                            message: "请选择一项款号修改",
                        });
                        return false;
                    }
                    const h = this.$createElement;
                    this.$msgbox({
                        title: '提示',
                        message: h('p', null, [
                            h('span', null, '是否确认修改该颜色?'),
                        ]),
                        showCancelButton: true,
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        type: 'warning',
                        beforeClose: (action, instance, done) => {
                            if (action === 'confirm') {
                                that.showBox2=true;
                                that.oldCol=that.ids2;
                                that.oldGir=that.ids22;
                                that.addAct2.color=that.ids2;
                                done();
                            } else {
                                done();
                            }
                        }
                    }).then(action => {

                    });
                },
                /*改变颜色确定*/
                sureBtn2(){
                    var that=this;
                    if(this.addAct2.color==''){
                        this.$notify.error({
                            title: '提示',
                            message: "请填写颜色",
                        });
                        return false;
                    }
                    $.ajax({
                        headers: {
                            'X-CSRF-TOKEN': $('meta[name="csrf_token"]').attr('content')
                        },
                        type: 'post',
                        url: '/allotment-manager/change-color',
                        data: {
                            new_color:that.addAct2.color,
                            color:that.oldCol,
                            girard:that.oldGir,
                        },
                        success: function (data) {
                            //console.log(data);
                            if(data.result.success){
                                that.$notify.success({
                                    title: '提示',
                                    message: "修改颜色成功",
                                });
                                that.grabble2(that.oldGir);
                                that.showThree=false;
                                that.showBox2=false;
                            }else{
                                that.$notify.error({
                                    title: '提示',
                                    message: data.result.errorMsg,
                                });
                            }
                        }
                    });
                },
                /*取消客户订单*/
                cancelPeople(){
                    var that=this;
                    if(this.ids3==''){
                        this.$notify.error({
                            title: '提示',
                            message: "请选择一个客户取消",
                        });
                        return false;
                    }
                    if(this.ids3.split(",").length>=2){
                        this.$notify.error({
                            title: '提示',
                            message: "请选择一个客户取消",
                        });
                        return false;
                    }
                    console.log(that.ids3)
                    const h = this.$createElement;
                    this.$msgbox({
                        title: '提示',
                        message: h('p', null, [
                            h('span', null, '是否确认取消该客户的订单?'),
                        ]),
                        showCancelButton: true,
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        type: 'warning',
                        beforeClose: (action, instance, done) => {
                            if (action === 'confirm') {
                                if(that.cancelPeopleFlag==true){
                                    that.cancelPeopleFlag=false;
                                    $.ajax({
                                        headers: {
                                            'X-CSRF-TOKEN': $('meta[name="csrf_token"]').attr('content')
                                        },
                                        type: 'post',
                                        url: '/allotment-manager/cancle-client-order',
                                        data: {
                                            client_ids:that.ids3,
                                            color:that.ids3Color,
                                            girard:that.ids3Girard,
                                        },
                                        success: function (data) {
                                            //console.log(data);
                                            if(data.result.success){
                                                that.$notify.success({
                                                    title: '提示',
                                                    message: "取消客户订单成功",
                                                });
                                                that.grabble3(that.remTwoGirard,that.remTwoColor);
                                                done();
                                                that.cancelPeopleFlag=true;
                                            }else{
                                                that.$notify.error({
                                                    title: '提示',
                                                    message: data.result.errorMsg,
                                                });
                                                that.cancelPeopleFlag=true;
                                            }
                                        }
                                    });
                                }
                            } else {
                                done();
                            }
                        }
                    }).then(action => {

                    });
                },
            }
        });
    </script>
@endsection
